package com.hongxun.modules.bss.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.bss.dao.DDrawLineDao;
import com.hongxun.modules.bss.entity.DDrawLineEntity;
import com.hongxun.modules.bss.service.DDrawLineService;



@Service("dDrawLineService")
public class DDrawLineServiceImpl implements DDrawLineService {
	@Autowired
	private DDrawLineDao dDrawLineDao;
	
	@Override
	public DDrawLineEntity queryObject(String guid){
		return dDrawLineDao.queryObject(guid);
	}
	
	@Override
	public List<DDrawLineEntity> queryList(Map<String, Object> map){
		return dDrawLineDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return dDrawLineDao.queryTotal(map);
	}
	
	@Override
	public void save(DDrawLineEntity dDrawLine){
		if(dDrawLine.getGuid()==null||dDrawLine.getGuid().equals("")) {

			dDrawLine.setGuid(UUID.randomUUID().toString());
		}
		dDrawLineDao.save(dDrawLine);
	}
	
	@Override
	public void update(DDrawLineEntity dDrawLine){
		dDrawLineDao.update(dDrawLine);
	}
	
	@Override
	public void delete(String guid){
		dDrawLineDao.delete(guid);
	}
	
	@Override
	public void deleteBatch(String[] guids){
		dDrawLineDao.deleteBatch(guids);
	}

	@Override
	public void insertOrReplaceOrDelete(List<DDrawLineEntity> entities) {
		for (DDrawLineEntity d : entities) {
			if (d.getDLDatastate().equals("删除")) {
				dDrawLineDao.delete(d.getGuid());
			} else {
				DDrawLineEntity dDrawLineEntity = dDrawLineDao.queryObject(d.getGuid());
				if (dDrawLineEntity == null) {
					dDrawLineDao.save(d);
				} else {
					dDrawLineDao.update(d);
				}
			}
		}
	}
}
